/**
 * Created with  SublimeText
 * @Author:      Lyle
 * @DateTime:    2016-11-07 11:21:08
 * @Description: 
 */

(function() {


    var switchTab = function(opt) {

        var opt = opt || {};

        /*
        defaults = {
            containerId : '',
            menuTabClass : '',
            menuTabActionClass:'',
            contentTabClass : '',
        }
        */

        this.bindEvt = function() {
            var tthis = this;
            $('#' + opt.containerId).find('.' + opt.menuTabClass).on('click', function() {
                var index = $(this).index();
                tthis.gotoTabs(index);
            });
        };

        this.gotoTabs = function(index) {
            $('#' + opt.containerId).find('.' + opt.menuTabClass).removeClass(opt.menuTabActionClass).eq(index).addClass(opt.menuTabActionClass);
            $('#' + opt.containerId).find('.' + opt.contentTabClass).hide().eq(index).show();
            if (opt.callback) { opt.callback(index) };
        };

    };

    if (typeof define === "function") {
        define(function(require, exports, module) {
            module.exports = switchTab;
        });
    }

})()
